package com.biodiv.community.converter;

import com.biodiv.community.converter.convert.BaseMapping;
import com.biodiv.community.entity.Post;
import com.biodiv.community.request.post.PostDTO;
import com.biodiv.community.response.post.PostVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

/**
 * @author: tianquan
 * @date: 2025-06-28  20:43
 */

@Mapper(uses = BaseMapping.class)
public interface PostConverter {

    PostConverter INSTANCE = Mappers.getMapper(PostConverter.class);

    @Mappings({
            @Mapping(source = "imageUrl", target = "imageUrl", qualifiedByName = "list2Str"),
            @Mapping(source = "tag", target = "tag", qualifiedByName = "list2Str"),
    })
    Post convert(PostDTO postDTO);

    @Mappings({
            @Mapping(source = "imageUrl", target = "imageUrl", qualifiedByName = "str2List"),
            @Mapping(source = "tag", target = "tag", qualifiedByName = "str2List")
    })
    PostVO convert(Post post);

}
